Crispo - Excel Challenge 49 2025

excel-challenges
weekly-exercises
Easy Sunday Excel Challenge
Published

December 7, 2025

Illustration for Crispo - Excel Challenge 49 2025

Challenge Description

Easy Sunday Excel Challenge

⭐ ⭐Sum ONLY quantities above 100

Solutions

library(tidyverse)
library(readxl)

path <- "2025-12-07/Challenge 82.xlsx"
input <- read_excel(path, range = "B2:C6")
test <- read_excel(path, range = "D2:D6")

result = input %>%
  separate_rows(`Price/Qty/Store No.`, sep = ", ") %>%
  separate_wider_delim(
    `Price/Qty/Store No.`,
    delim = "/",
    names = c("Price", "Qty", "Store No.")
  ) %>%
  mutate(Qty = ifelse(as.integer(Qty) > 100, as.integer(Qty), 0L)) %>%
  summarise(`Total Quantity` = sum(as.integer(Qty)), .by = Date)

all.equal(result$`Total Quantity`, test$`Total Qty`)
# [1] TRUE
  • Logic:

    • Reads the workbook range needed for the challenge

    • Aggregates or ranks values at the correct grouping level

    • Builds the intermediate helper columns that drive the final answer

  • Strengths:

    • The R solution stays compact and mirrors the workbook logic closely.
  • Areas for Improvement:

    • The code assumes the workbook layout and named ranges remain stable.
  • Gem:

    • The best part of the solution is choosing a tidy intermediate shape before producing the final answer.
import pandas as pd

path = "2025-12-07/Challenge 82.xlsx"
input_df = pd.read_excel(path, usecols="B:C", skiprows=1, nrows=4)
test = pd.read_excel(path, usecols="D:D", skiprows=1, nrows=4)

result = (
    input_df
    .assign(**{"Price/Qty/Store No.": input_df["Price/Qty/Store No."].str.split(", ")})
    .explode("Price/Qty/Store No.")
    .reset_index(drop=True)
    .assign(**{
        "Price": lambda df: df["Price/Qty/Store No."].str.split("/", expand=True)[0],
        "Qty": lambda df: pd.to_numeric(
            df["Price/Qty/Store No."].str.split("/", expand=True)[1],
            errors="coerce"
        ).fillna(0).astype(int).where(lambda x: x > 100, 0)
    })
    .groupby("Date", as_index=False)
    .agg(**{"Total Quantity": ("Qty", "sum")})
)

print(result["Total Quantity"].equals(test["Total Qty"]))
# True
  • Logic:

    • Reads the workbook range needed for the challenge

    • Aggregates or ranks values at the correct grouping level

    • Builds the intermediate helper columns that drive the final answer

  • Strengths:

    • The Python version keeps the same rule in a direct pandas-oriented workflow.
  • Areas for Improvement:

    • As with the R version, any workbook layout change would require small adjustments.
  • Gem:

    • The implementation stays close to the stated challenge instead of adding unnecessary complexity.

Difficulty Level

This task is easy to moderate:

  • The business rule is readable, but the workbook still needs a few careful transformation steps.